package algotithm.leetcode.dichotomy.test1237;

import java.util.ArrayList;
import java.util.List;


class CustomFunction{

    public int f(int x, int y) {
        return x+y;
    }

}
/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/8-9:22
 */
public class Solution {


    public static void main(String[] args) {
        Solution solution = new Solution();
        CustomFunction customFunction = new CustomFunction();
        List<List<Integer>> list = solution.findSolution(customFunction, 10);
        for (List<Integer> num : list) {
            System.out.println(num);
        }
    }


    public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
        List<List<Integer>> res = new ArrayList<>();
        int l = 1, r = 1000;
        while (l <= 1000 && r >= 1) {
            if (customfunction.f(l,r) < z) {
                l++;
            } else if (customfunction.f(l,r) > z) {
                r--;
            } else {
                List<Integer> list = new ArrayList<>();
                list.add(l++);
                list.add(r--);
                res.add(list);
            }
        }
        return res;
    }

}
